package com.dullwolf.controller.osu;

import com.dullwolf.cmd.osu.OsuHomeCommand;
import com.dullwolf.controller.BaseController;
import com.dullwolf.model.Osu;
import com.dullwolf.pojo.CqMsg;
import com.dullwolf.service.BotService;
import com.dullwolf.utils.JsonUtils;
import io.jboot.core.rpc.annotation.JbootrpcService;
import io.jboot.web.controller.annotation.RequestMapping;


/**
 * @author dullwolf
 */

@RequestMapping("/osu")
public class OsuController extends BaseController {

    @JbootrpcService
    private BotService botService;


    public void getMsg() {
        Osu osu = jsonToModel(Osu.class);
        Object convert = JsonUtils.convert(osu.toJson());
        String jsonString = JsonUtils.getJsonString(convert);
        CqMsg cqMsg = JsonUtils.getObjectByJson(jsonString, CqMsg.class);

        if (null != cqMsg.getMessage()) {
            String msgData = cqMsg.getMessage().trim();
            boolean pre = msgData.startsWith("!") || msgData.startsWith("！") || msgData.startsWith("*");
            if(pre){
                botService.sendCqMsg(cqMsg.getMessageType(), cqMsg);
            }

        }
        SuccessResult("发送成功");
    }



}
